﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DBEntity;
using System.IO;
//using Shell32;
using Microsoft.WindowsAPICodePack.Shell;

namespace iver
{
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            iverDB db = new iverDB();
            var list = (from u in db.apInfoType
                        select u);
            int count = list.Count();
            this.mydiv.InnerHtml = count.ToString();
            //string temp = "";
            //List<string> strs = iver.Controllers.Help.GetFileDetailInfo(System.Web.HttpContext.Current.Server.MapPath("up/thumb/00f22f4d61d44443a1e629d090d61053.jpg"));
            //for (int i = 0; i < strs.Count; i++)
            //{
            //    temp += strs[i] + "<br/>";
            //}
            //string filePath = @"E:\test.jpg";
            //mydiv.InnerHtml= iver.Controllers.Help.GetFileAttr(filePath).Subject.Value;


            //Microsoft.WindowsAPICodePack.Shell.PropertySystem.ShellPropertyWriter propertyWriter = file.Properties.GetPropertyWriter();
            //propertyWriter.WriteProperty(Microsoft.WindowsAPICodePack.Shell.PropertySystem.SystemProperties.System.Title,"我是标题1");
            //propertyWriter.Close();
            //string[] oldAuthors = file.Properties.System.Author.Value;

            //mydiv.InnerHtml = iver.Controllers.Help.GetValueByKey("创建时间", strs);
            //mydiv.InnerHtml = System.Text.RegularExpressions.Regex.Split("abcde : asdfsadf", @"\:\s")[0];
            //mydiv.InnerHtml = iver.Controllers.Help.GetFileDetailInfo(System.Web.HttpContext.Current.Server.MapPath("up/thumb/00f22f4d61d44443a1e629d090d61053.jpg"), "创建时间");
            //mydiv.InnerHtml = iver.Controllers.Help.GetFileDetailInfo("e:/ychsyxx", -1);

            //System.Text.RegularExpressions.Regex rex = new System.Text.RegularExpressions.Regex(@"[^\s]");


            //iverdb db = new iverdb();
            //var list = (from u in db.apinfo
            //            where u.cover != ""
            //            select new
            //            {
            //                u.cover,
            //            });
            //int count = list.count();

            //List<string> slist = new List<string>();

            //foreach (var item in list)
            //{
            //    slist.Add(System.IO.Path.GetFileNameWithoutExtension(item.cover));

            //}
            ////1350 885 465
            //string rootpath = System.Web.HttpContext.Current.Server.MapPath("up/thumb");
            //string[] strs = System.IO.Directory.GetFiles(rootpath, "*.*", System.IO.SearchOption.AllDirectories);
            //List<string> rlist = new List<string>();
            //for (int i = 0; i < strs.Length; i++)
            //{
            //    bool flag = false;
            //    string Item = System.IO.Path.GetFileNameWithoutExtension(strs[i]);
            //    for (int j =0;j< slist.Count; j++)
            //    {
            //        if(slist[j] == Item)
            //        {
            //            flag = true;
            //            break;
            //        }
            //    }
            //    if (flag)
            //    {
            //        rlist.Add(strs[i]);
            //    }

            //}

            //string temp = "";
            //for(int i = 0; i < rlist.Count; i++)
            //{
            //    temp += rlist[i] + "<br/>";
            //}
            //mydiv.InnerHtml = rlist.Count + "<br/>" + temp;

            //string rootpath = System.Web.HttpContext.Current.Server.MapPath("up");
            //string[] strs = System.IO.Directory.GetFiles(rootpath, "*.MP4", System.IO.SearchOption.AllDirectories);

            //List<string> list = new List<string>();
            //for (int i = 0; i < strs.Length; i++)
            //{
            //    list.Add(System.IO.Path.GetFullPath(strs[i]).Replace(rootpath, "").Replace(@"\", "/"));
            //}
            //iverDB db = new iverDB();
            //string temp = "";
            //int mycount = 0;
            //for (int i = 0; i < list.Count; i++)
            //{
            //    string str = list[i];

            //    //var rlist = (from u in db.apInfo
            //    //             where u.body.Contains(list[i])
            //    //             select u);

            //    if (db.apInfo.Where(p => p.body.Contains(str)).Count() == 0)
            //    {
            //        temp += $"{list[i]}<br/>";
            //        mycount++;
            //    }
            //}
            //mydiv.InnerHtml = $"{mycount}<br/>" + temp;


            //string temp = "";
            //for (int i = 0; i < list.Count; i++)
            //{
            //    temp += $"{list[i]}<br/>";
            //}
            //mydiv.InnerHtml = temp;

            //string OldPath = Server.MapPath("/up/infoFile/160bae5db6b74d9d98738d417d18014a.jpg");
            //string fileName = System.IO.Path.GetFileName(OldPath);
            //string pathName = "/up/" + "thumb" + "/";
            //string createDir = System.Web.HttpContext.Current.Server.MapPath("~" + pathName);
            //if (!System.IO.Directory.Exists(createDir))
            //{
            //    System.IO.Directory.CreateDirectory(createDir);
            //}
            //string NewPath = System.Web.HttpContext.Current.Server.MapPath(pathName + fileName);
            //if (!System.IO.File.Exists(NewPath))
            //{
            //    iver.Controllers.Help.MakeThumbnail(OldPath, NewPath, 300, 200, "W");
            //    this.mydiv.InnerHtml = NewPath;
            //}
            //else
            //{
            //    this.mydiv.InnerHtml = "已存在";
            //}


        }
        /// <summary>
        /// 写文件在log/log.txt下
        /// </summary>
        /// <param name="str">要写入的字符串</param>
        public void SaveNote(string str)
        {

            string myDir = AppDomain.CurrentDomain.BaseDirectory + @"config\";
            if (!System.IO.Directory.Exists(myDir))
            {
                System.IO.Directory.CreateDirectory(myDir);
            }
            System.IO.StreamWriter sw = System.IO.File.CreateText(myDir + "home.js");

            //System.IO.StreamWriter sw = System.IO.File.AppendText(myDir + "log.js");

            sw.WriteLine(str);
            sw.Flush();
            sw.Close();

        }
        protected void myBtn_Click(object sender, EventArgs e)
        {

        }
    }
}